package cn.yanxiaohui.common.vo;

/**
 * ajax请求返回的实体类
 * @author yanxh
 *
 */
public class ActionResult {

    private Integer code; // 请求结果状态

    private Object message; // 请求结果信息

    private static final Integer DEFAULT_SUCCESS_CODE = 200; // 请求成功默认状态位

    private static final Integer DEFAULT_ERROR_CODE = 500; // 请求失败默认状态位

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }

    /**
     * 构造器
     */
    public ActionResult() {}

    public ActionResult(Integer code, Object message) {
        super();
        this.code = code;
        this.message = message;
    }

    /**
     * 静态方法列表
     */
    public static ActionResult success(Object message) {
        return new ActionResult(DEFAULT_SUCCESS_CODE, message);
    }

    public static ActionResult success() {
        return ActionResult.success(null);
    }

    public static ActionResult error(Object message) {
        return new ActionResult(DEFAULT_ERROR_CODE, message);
    }

    public static ActionResult error(Integer code, Object message) {
        return new ActionResult(code, message);
    }

}